// 预览面打包
import path from 'path';
import config from './vite.config-design.js';
import VappMeta from './AssetPack/vapp-meta-data.json';
import externalGlobals from 'rollup-plugin-external-globals';

config.publicDir = '_public'; // 给个不存在的目录，防止复制public下不需要的文件到dist文件夹
config.build.lib.entry = path.resolve(__dirname, 'src/components/index-preview.js');

config.build.rollupOptions.output.dir = './AssetPack/web/web-components/lib/preview';
config.build.rollupOptions.output.entryFileNames = `${VappMeta.xvueNameSpace}.preview.js`;
config.build.rollupOptions.output.assetFileNames = `${VappMeta.xvueNameSpace}.preview.[ext]`; // css
config.build.rollupOptions.plugins = [externalGlobals({
  '@hw-seq/sweet-ui-base': 'SweetBase',
  '@hw-seq/sweet-ui-icons': 'SweetUIIcon',
  vue: 'Vue',
  'element-plus': 'ElementPlus',
  'element-plus/es': 'ElementPlus',
  vuex: 'Vuex',
  'vue-router': 'VueRouter',
  axios: 'axios',
  echarts: 'echarts',
  'xe-utils': 'XEUtils',
  'vxe-table': 'VXETable',
})];

export default config;
